package com.briup.recognition.service.impl;

import com.briup.recognition.bean.Category;
import com.briup.recognition.bean.CategoryExample;
import com.briup.recognition.dao.CategoryMapper;
import com.briup.recognition.service.ICategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: recognition
 * @description:
 * @author: charles
 * @create: 2021-03-28 15:11
 **/

@Service
public class CategoryServiceImpl implements ICategoryService {

    @Resource
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> query() {
        CategoryExample example = new CategoryExample();
        // 条件

        return categoryMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(Category category) {
        if(category.getId()!=null){
            categoryMapper.updateByPrimaryKey(category);
        } else {
            categoryMapper.insert(category);
        }
    }

    @Override
    public void deleteById(long id) {
        categoryMapper.deleteByPrimaryKey(id);
    }
}